function Queue() {
  let p = Queue.prototype;
  this.item = [];
  p.enqueue = function() {
    for (let i = 0; i < arguments.length; i++) {
      this.item.push(arguments[i]);
    }
  };
  p.dequeue = function() {
    return this.item.shift();
  };
  p.front = function() {
    return this.item[0];
  };
  p.isEmpty = function() {
    if (this.item.length === 0) return true;
    else return false;
  };
  p.size = function() {
    return this.item.length;
  };
  p.toString = function() {
    return this.item.join(" ");
  };
}

let q = new Queue();
q.enqueue(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
console.log(q.toString());

q.dequeue();
console.log(q.toString());

console.log(q.front());

console.log(q.isEmpty());
console.log(q.size());
/**
 * 猴子选大王 |  击鼓传花
 */
function drumSpreading(n, arr) {
  let qq = new Queue();
  qq.enqueue(...arr);
  let i = 0;
  while (qq.size() > 1) {
    i++;
    if (i == n) {
      qq.dequeue();
      i = 0;
    } else qq.enqueue(qq.dequeue());
  }
  return qq.toString();
}
let ret = drumSpreading(2, [1, 2, 3]);
console.log(ret);
